from curl_cffi import requests
from lxml import etree





cookies = {
    'XSRF-TOKEN': '317e7e8e-fa08-417b-9785-79bff7b5f4dc',
    'cna': 'fp+MITM4jQQBASQIgiAV1f/z',
    'xlly_s': '1',
    'isg': 'BH5-hFeAmyy1dM8I6Yi3wFlZz5TAv0I5OCGFHiiG50G8yx6lkEx7SaUoR5cHdzpR',
    'tfstk': 'gATEnp1OO23Eb3ysRdQzg0VoHc_dyakjaU65ZQAlO9XhdXQPqLvhqUipOauPQLI5K9GdzgvkKgv5FBNpXKO0ReidPz7dyaDjhqgXOBQRrmY_M8XpsCCo16bEUpXAyaDjCqgX9BQJLH5DK9Ai__17-JvlKG4GBsZhr9juIlfcITbkEM2GS_fztJjhK1cNwOfhrMX3Sf55I6blrLAi__HZyEY8Q_sn1EsRnCwi2GWDtOzuuSChxJdgVz4oP1SFnMDQzz5GTMWDtOkEI5qNjQIyy7UPVBxvesv3KYWJ7CYHmKD_A9xVaItynbZd1g8d7TYnkSWM8Q8Nvhw3xs7FLiYhYSGv9gxw7wTneod6_9jV5hitdg_eLnBAxcH9UCWBEeSgLA6WcCThbKD_7LIyqe_M-A0V46yRscTHyHyu4MfO_tGZ_Pd2p1cjVoq42uIK91WjtMq82Mf0Pk8SLuERvB1NhXVl.',
}

headers = {
    'accept': 'application/json, text/plain, */*',
    'accept-language': 'zh-CN,zh;q=0.9',
    'priority': 'u=1, i',
    'referer': 'https://search.damai.cn/search.htm',
    'sec-ch-ua': '"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36',
    'x-xsrf-token': '317e7e8e-fa08-417b-9785-79bff7b5f4dc',
    # 'cookie': 'XSRF-TOKEN=317e7e8e-fa08-417b-9785-79bff7b5f4dc; cna=fp+MITM4jQQBASQIgiAV1f/z; xlly_s=1; isg=BH5-hFeAmyy1dM8I6Yi3wFlZz5TAv0I5OCGFHiiG50G8yx6lkEx7SaUoR5cHdzpR; tfstk=gATEnp1OO23Eb3ysRdQzg0VoHc_dyakjaU65ZQAlO9XhdXQPqLvhqUipOauPQLI5K9GdzgvkKgv5FBNpXKO0ReidPz7dyaDjhqgXOBQRrmY_M8XpsCCo16bEUpXAyaDjCqgX9BQJLH5DK9Ai__17-JvlKG4GBsZhr9juIlfcITbkEM2GS_fztJjhK1cNwOfhrMX3Sf55I6blrLAi__HZyEY8Q_sn1EsRnCwi2GWDtOzuuSChxJdgVz4oP1SFnMDQzz5GTMWDtOkEI5qNjQIyy7UPVBxvesv3KYWJ7CYHmKD_A9xVaItynbZd1g8d7TYnkSWM8Q8Nvhw3xs7FLiYhYSGv9gxw7wTneod6_9jV5hitdg_eLnBAxcH9UCWBEeSgLA6WcCThbKD_7LIyqe_M-A0V46yRscTHyHyu4MfO_tGZ_Pd2p1cjVoq42uIK91WjtMq82Mf0Pk8SLuERvB1NhXVl.',
}

params = {
    'keyword': '',
    'cty': '',
    'ctl': '',
    'sctl': '',
    'tsg': '0',
    'st': '',
    'et': '',
    'order': '1',
    'pageSize': '30',
    'currPage': '1',
    'tn': '',
}


for i in range(1,6):
    url = f"https://search.damai.cn/searchajax.html?keyword=&cty=&ctl=&sctl=&tsg=0&st=&et=&order=1&pageSize=30&currPage={i}&tn="
    responses = requests.get(url, params=params, cookies=cookies, headers=headers)
    datas = responses.json()['pageData']['resultData']
    for data in datas:
        print(data)
#
# ① 大麦网演出列表
# URL: https://search.damai.cn/searchajax.html
# 考点: 动态 sign（md5 拼时间戳+页码），30 s 过期
# 目标: 用 Python 算出 sign，抓 5 页 JSON 即通关
# ② 拉勾网搜索
# URL: https://www.lagou.com/jobs/positionAjax.json
# 考点: X-Anit-Forge-Code / Token + Cookie 绑定
# 目标: 纯代码拿第 2 页职位 JSON
# ③ 当当商品评论
# URL: https://product.dangdang.com/index.php?r=comment/list
# 考点: 参数 sign=md5(盐+productId+pageIndex+timestamp)
# 目标: 抓 100 页评论并去重
# ④ 美团外卖商家列表
# URL: https://www.meituan.com/meishi/api/poi/getMerchantList
# 考点: sign=md5(path+query+body+ts)，20 s 有效期
# 目标: 连续翻 10 页商家（含店名+评分+月销量）
# ⑤ 小红书笔记搜索
# URL: https://edith.xiaohongshu.com/api/sns/web/v1/search/notes
# 考点: 本地 WASM 计算 x-s、x-t 签名
# 目标: 关键词“杭州美食”抓 100 条笔记标题+点赞数
# ⑥ 网易云音乐评论
# URL: https://music.163.com/weapi/v1/resource/comments/R_SO_4_186016
# 考点: RSA+AES 加密 params/encSecKey
# 目标: 拿到《晴天》前 500 条热评
# ⑦ 抖音 Web 搜索
# URL: https://www.douyin.com/aweme/v1/web/search/item
# 考点: X-Bogus + 指纹链 + Cookie 绑定
# 目标: 关键词“露营”抓 50 条视频标题+播放量
# ⑧ 淘宝 Search
# URL: https://s.taobao.com/search
# 考点: 多层加密 sign + 滑块/无感验证 + 风控打分
# 目标: 拿到第一页商品即算摸到 T5 门槛

